/*
 * insert_sort.cpp
 *
 *  Created on: May 3, 2014
 *      Author: Lhmily
 */
#include "../header/base.h"
#include "../header/compare.h"

template<typename Elem, typename Comp>
void insert_sort(Elem array[], int size) {
	for (int i = 1; i < size; ++i)
		for (int j = i; (j > 0) && (Comp::prior(array[j], array[j - 1])); --j)
			swap(array, j, j - 1);
}

template<typename E, typename Comp>
void sort(E* array, int n) {
	insert_sort<E, Comp>(array, n);
}

#include "../test.cpp"


int main(int argc, char **argv) {

	return testMain<minintCompare>(argc, argv); //
}
